home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / MFC_Samples / chkbook / chkrec.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  3.1 KB  |  105 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1999 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. #ifndef __INC_CHKREC_H__
  12. #define __INC_CHKREC_H__
  13.  
  14. #define FIRST_CHECK_NO 1000
  15. #define NO_OF_CHECKS 100
  16.  
  17.  
  18. class CCheckRecord
  19. {
  20. friend class CCheckBookFile;
  21. protected:
  22.     DWORD   m_dwCents;
  23.     TCHAR   m_szPayTo[40];
  24.     TCHAR   m_szDate[10];
  25.     TCHAR   m_szMemo[40];
  26. public:
  27.     CCheckRecord();
  28.     void Reset();
  29.  
  30.     CCheckRecord* GetCheck() { return this; }
  31.     void GetCheck(DWORD dwCents, CString& strPayTo,
  32.         CString& strDate, CString& strMemo);
  33.     void SetCheck(DWORD dwCents, CString strPayTo,
  34.         CString strDate, CString strMemo);
  35.  
  36.     DWORD GetCents() { return m_dwCents; }
  37.     void GetPayTo(CString& strPayTo) { strPayTo = m_szPayTo; }
  38.     void GetDate(CString& strDate) { strDate = m_szDate; }
  39.     void GetMemo(CString& strMemo) { strMemo = m_szMemo; }
  40.     
  41.     void SetCents(DWORD dwCents) { m_dwCents = dwCents; }
  42.     void SetPayTo(CString strPayTo) {         
  43.         _tcsncpy(m_szPayTo, strPayTo, sizeof(m_szPayTo)/sizeof(TCHAR) - 1);
  44.         m_szPayTo[39] = '\0'; }
  45.     void SetDate(CString strDate) { 
  46.         _tcsncpy(m_szDate, strDate, sizeof(m_szDate)/sizeof(TCHAR) - 1);
  47.         m_szDate[9] = '\0'; }
  48.     void SetMemo(CString strMemo) { 
  49.         _tcsncpy(m_szMemo, strMemo, sizeof(m_szMemo)/sizeof(TCHAR) - 1);
  50.         m_szMemo[39] = '\0'; }
  51.  
  52.     BOOL IsEmpty();
  53.     BOOL IsSame(DWORD dwCents, CString strPayTo,
  54.         CString strDate, CString strMemo);
  55. };
  56.  
  57. class CCheckBookFile
  58. {
  59. public:
  60.     CString m_strFileName;        // File name information
  61. protected:
  62.     UINT m_nRecordCount;        // count of records in the file
  63.     UINT m_nRecordLength;       // length of fixed-length records
  64.     CFile m_file;                // Current .chb file
  65. public:
  66.     CCheckBookFile();
  67.     ~CCheckBookFile();
  68.     UINT GetRecordCount() { return m_nRecordCount; }
  69.     UINT GetRecordLength() { return m_nRecordLength; }
  70.     void IncRecordCount() { m_nRecordCount++; }
  71.     void DelRecordCount() { m_nRecordCount--; }
  72.     void Reset() { m_nRecordCount = 0;
  73.         m_nRecordLength = sizeof(CCheckRecord); if (m_file.m_hFile != -1) m_file.Close();}
  74.     BOOL New();
  75.     BOOL Open();
  76.     BOOL WriteRecord(UINT nPos, CCheckRecord* pRecord);
  77.     BOOL ReadRecord(UINT nPos, CCheckRecord* pRecord);
  78. };
  79.  
  80. class CCheckBook
  81. {
  82. public:
  83.     CCheckBookFile m_fileCheckBook;
  84. protected:
  85.     CCheckRecord m_check;
  86.     BOOL         m_bExists;
  87. public:
  88.     CCheckBook();
  89.  
  90.     void Reset();
  91.     CCheckRecord* GetCheck(int nCheck);
  92.     int SetCheck(int nCheck, DWORD dwCents, CString strPayTo,
  93.         CString strDate, CString strMemo);
  94.  
  95.     BOOL IsCheckEmpty(int nCheck);
  96.     BOOL IsCheckSame(int nCheck, DWORD dwCents, CString strPayTo,
  97.         CString strDate, CString strMemo);
  98.     BOOL New();
  99.     BOOL Open();
  100.     BOOL DoesBookExist() { return m_bExists; }
  101.     int GetNextNewCheckNo() {return (m_fileCheckBook.GetRecordCount() + FIRST_CHECK_NO);}
  102. };
  103.  
  104. #endif // __INC_CHKREC_H__
  105.